package com.yoda.mall.autoconfig;

import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import com.yoda.mall.autoconfig.properties.OssProperties;
import com.yoda.mall.autoconfig.template.OssTemplate;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;

/**
 * @author wangjia
 * @date 2022/12/16
 * @Description
 */
//SpringBoot自动装配加载SmsProperties
@EnableConfigurationProperties({OssProperties.class})
public class YoDaAutoConfiguration {

    public static void main(String[] args) {
        SpringApplication.run(YoDaAutoConfiguration.class, args);
    }
    @Bean
    public OssTemplate ossTemplate(OssProperties ossProperties) {
        return new OssTemplate(ossProperties);
    }

    @Bean
    public OSS ossClient(OssProperties properties){
        return new OSSClientBuilder().build(properties.getEndpoint(), properties.getAccessKeyId(), properties.getAccessKeySecret());
    }
}
